Skip to content

Add unit tests for cloud API datasets module#14

Merged
stevevanhooser merged 2 commits into
mainfrom
claude/fix-listdatasets-error-6Hkhh
Mar 11, 2026
Merged

Add unit tests for cloud API datasets module#14
stevevanhooser merged 2 commits into
mainfrom
claude/fix-listdatasets-error-6Hkhh

Conversation

@stevevanhooser

Copy link
Copy Markdown
Contributor

Summary

This PR adds comprehensive unit tests for the ndi.cloud.api.datasets module, covering the core dataset operations without requiring network access.

Key Changes

  • Added TestListDatasets class with three test cases:

    • Verifies listDatasets() resolves org_id from client config when not explicitly provided
    • Confirms explicit org_id parameter takes precedence over client config
    • Ensures ValueError is raised when org_id is missing from both parameter and config
  • Added TestListAllDatasets class:

    • Tests listAllDatasets() functionality without explicit org_id
  • Added TestCreateDataset class with two test cases:

    • Verifies createDataset() uses org_id from client config
    • Ensures ValueError is raised when org_id is missing
  • Implemented _make_client() helper function to create mock CloudClient instances with configurable organization IDs

Notable Implementation Details

  • All tests use unittest.mock.MagicMock to avoid network calls
  • Tests validate both successful operations and error conditions
  • Mock client is configured with realistic API responses and endpoints
  • Tests follow the pattern of optional org_id parameter with fallback to client config

https://claude.ai/code/session_011B2Dj4a62UZAffje5gGero

claude added 2 commits March 11, 2026 12:19
The fix from 804dd90 correctly removed @validate_call from listDatasets
(and createDataset/listAllDatasets), making org_id optional and resolved
from client config. These unit tests verify the fix works and guard
against regression.

https://claude.ai/code/session_011B2Dj4a62UZAffje5gGero
@stevevanhooser stevevanhooser merged commit 0892b54 into main Mar 11, 2026
4 checks passed
@stevevanhooser stevevanhooser deleted the claude/fix-listdatasets-error-6Hkhh branch March 14, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants